package com.zpark.evaluate;

import com.zpark.entity.EvaluateData;
import com.zpark.entity.EvaluateReport;
import com.zpark.entity.HistoryData;
import com.zpark.entity.RiskFactor;

import java.util.Set;

/***
 * 登录地评估
 */
public class AreaEvaluate  extends Evaluate{

    public AreaEvaluate() {
        super(RiskFactor.AREA);
    }

    @Override
    public void eval(EvaluateData evaluateData, HistoryData historyData, EvaluateReport evaluateReport, EvaluateChain evaluateChain) {

        //1.判断登录地是否有风险
        boolean isRisk = doEval(evaluateData.getCityName(), historyData.getHistoryCities());

        //把登录地评估结果放入到评估报告中
        evaluateReport.signReport(RiskFactor.AREA,isRisk);

        //2.让评估链继续执行下一个评估（责任）
        evaluateChain.doChain(evaluateData,historyData,evaluateReport);
    }

    /**
     * 登录地评估：判断登录地是否有风险
     * @param cityName
     * @param historyCities
     * @return
     */
    private boolean doEval(String cityName, Set<String> historyCities){
        if(historyCities==null){
            return false;//没有风险
        }
        if(historyCities.contains(cityName)){
            //当前评估的数据，在历史数据中
            return false;//
        }
        return true;
    }
}
